package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;

public class BankReport {
	
	public static String printBank(Bank bank)
			throws AccountDoesntExistsException {
		StringBuffer sbuf = new StringBuffer();
		if (bank == null) System.out.println("bank is null");
		Client[] clients = bank.getClients();
			for (Client cl : clients) {
				if (cl != null) {
					if (cl.getAccount() == null)
						throw new AccountDoesntExistsException();
					sbuf.append("Client " + cl.getClientSalutation() 
							+ ", gender is " + cl.getGender()
							+ ", account is " + cl.getAccount().getClass().getSimpleName()
							+ ", balance = " + cl.getAccount().toString()
							+ "\n");
					if (sbuf.toString() == null) System.out.println("sbuf is null");
					System.out.println(sbuf.toString());
				} else System.out.println("client is null");
			}
			return sbuf.toString();
		}
	}

